package com.credit.mola.app.utils.http

import com.credit.mola.app.BuildConfig
import com.credit.mola.app.utils.analysis.AnalyticsUtil
import com.credit.mola.app.utils.config.Configs
import org.json.JSONObject

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/5/21 15:19
 * @Annotation： 接口地址
 */
object AppUrls {

    /**
     * https://www.maxpas-info.online
     * http://159.138.165.72
     */
    var APP_URL = "https://www.maxpas-info.online"

    object URL {
        /**
         * 地区转发
         * /v1/timezonePath
         */
        const val TIMEZONE = "/jucaKRhC2h5QRCEDIrujBg"
        /**
         * APP业务统一请求接口
         * /v1/commonApi
         */
        const val COMMON = "/xlMreBId3YqJ4D20bMgdcQ"
        /**
         * 文件上传
         * /v1/imageUpload
         */
        const val FILE = "/l9C9uYGFkgQT3rkeFYY3Gng"
    }

    object PATH {
        /**
         * APP配置参数 Path
         * /v1/getAppShowInfo
         */
        const val APP_INFO = "lyTIcUOBdDp6wxZ423V1A"

        /**
         * 发送验证码
         * /v1/smsCode
         */
        const val SEND_SMS = "l4jVJfBII9zXUOtrcFrb2sQ"

        /**
         * 发送whatsapp验证码
         * /v1/sendWhatAppMessage
         */
        const val WHATSAPP_SEND_CODE_PATH = "hQYjAYbsGt5Hr7Iiaw"

        /**
         * 校验whatsapp验证码
         *  /v1/checkWhatAppMessageCode
         */
        const val WHATSAPP_CHECK_CODE_PATH = "l7VaZTo9kXjWbjSdfXUKYw"

        /**
         * 登录
         * /v1/userLogin
         */
        const val LOGIN = "TgzgLbGhaOL8pzeZmI6PMQ"

        /**
         * 无验证码登录
         * /v1/userLoginNoCode
         */
        const val LOGIN_NO_CODE = "D6LAn3l3RJSnc3VNu1WVQ"

        /**
         * 用户流程状态
         * /v1/userProcess
         */
        const val PROCESS = "y80TpWDrcXrOcA3o509g"
        /**
         * 保存用户图片信息（身份证、护照、驾驶证、人脸）
         * /v1/ocrInfo
         */
        const val OCR_INFO = "eY5BChC2IndOHGO0KNt9Zw"

        /**
         * 用户贷款额度
         * /v1/loanLimit
         */
        const val LIMIT = "l2n8p0JJlsfSsr8k0VWvslg"

        /**
         * 新用户贷款额度预览信息
         * /v1/getLoanApplyDetail
         */
        const val CREDIT_APPLY = "l4mIZOe1QRevyMkY3A0PxQ"

        /**
         * 可选额度和期限的预览信息(老用户)
         * /getLoanDetailPageForDays
         */
        const val CREDIT_APPLY_CUSTOM_LIMIT = "dzD5nIuGUUDuCCez0IJhyQ"

        /**
         * 创建贷款申请订单
         * /v1/loanApply
         */
        const val CREDIT_APPLY_ORDER_CREATE = "XhfnkaE3wLcgNay7Ad29zg"

        /**
         * 贷款还款信息
         * /v1/repayInfo
         */
        const val CREDIT_REPAYMENT_INFO = "V6g4LmUqAmVqeu2EFWmniw"
        /**
         * 贷款还款信息
         * /v1/getOrderRepayH5
         */
        const val CREDIT_REPAYMENT_URL = "KjEmC1jxSbhSLzc6V0Hvew"

        /**
         * 账户列表
         * /v1/getBindCardList
         */
        const val ACCOUNT_LIST = "cOey3o2hktdoH4t0TTQh8w"
        /**
         * 已绑定账户列表（法语）
         * /v2/fetchBoundBankAccount
         */
        const val ACCOUNT_LIST_FRENCH = "JgJwD5Ua8E5IElfb0dvoQ"
        /**
         * 添加账户
         * /v2/bindBankAccount
         */
        const val ACCOUNT_ADD = "FupHu5MR1gmLNxOs7joyQ"
        /**
         * 删除已绑定的账户
         * /v1/deleteBoundBankAccount
         */
        const val ACCOUNT_DELETE = "APbyEyLNDHJdiYTnWuyIuA"
        /**
         * 评价弹框
         * /v1/fetchStarWindowConfig
         */
        const val STAR_COMMENT = "l8sNYRSIu8NBuPVE8U2hBw"

        /**
         * 提交意见反馈
         * /v1/feedback
         */
        const val FEEDBACK_SUBMIT = "wY9xKDi1AUMqNYxwm2fMqw"

        /**
         * 推荐APP列表
         * /v1/userDeniedDc
         */
        const val RECOMMEND_APP_LIST = "BgSb4hn8k0bkXsr5wWi4A"
        /**
         * 事件埋点
         * /v1/userBuriedPoint
         */
        const val TRACK_EVENT = "Bqrkkpwj1wzVZfdAmVg"
        /**
         * 事件批量埋点
         * v1/userBuriedPointForBatch
         */
        const val TRACK_EVENT_BATCH = "Qv9UEtrui0J34MI6v6YWOQ"

        /**
         * 清除用户数据(新)
         * /v1/dropUserData
         */
        const val USER_DATA_CLEAR = "q2ZerilVY1lZLRX2iNrYKQ"

        /**
         * 产品额度是否有提升
         * /v1/amountIsUp
         */
        const val LIMIT_INCREASED_PATH = "r7uF5ADxk2ZxoZqUR3xA"

        /**
         * 设备数据上传状态
         * /v1/queryDeviceInfoTypes
         */
        const val DEVICE_INFO_TYPES = "TvcRX9A2jQwjJ5tWIEUDpw"

        /**
         * 获取绑卡支持的银行列表
         * /v1/fetchBankCodes
         */
        const val BIND_CARD_BANK_LIST = "S3aJ5xPzTnbC6zLSqrzAmA"
    }

    /**
     * 数据分析path
     */
    object ANALYSIS_PATH {
        /**
         * google install
         * /v1/channelInstallTemp
         */
        const val ANALYSIS_GOOGLE_INSTALL_PATH = "/l4dgkLgM4OiraDvhSmmB6Uw"
        /**
         * adjust install
         * /v1/adjustInstallTemp
         */
        const val ANALYSIS_ADJUST_INSTALL_PATH = "/zCazEswpalHGhY1RrROqA"
        /**
         * facebook install
         * /v1/saveFbAppData
         */
        const val ANALYSIS_FACEBOOK_INSTALL_PATH = "/P255np9RducZDhKlWCsnA"
        /**
         * Firebase install
         * /v1/fireBase/save
         */
        const val ANALYSIS_FIREBASE_INSTALL_PATH = "/ChfSGvVETkNdSTtCMJ631Q"
    }

    /**
     * 获取请求Url
     */
    fun getHttpUrl(url: String): String{
        //地区转发
        val timeZone = Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE)
        if (timeZone.isNotEmpty()){
            return "$APP_URL/$timeZone$url"
        }
        return "$APP_URL$url"
    }

    fun JSONObject.addCommonParams(): JSONObject {
        apply {
            put("product", Configs.AppName)                                                   //  产品 APP名称
            put("token", Configs.getSPString(Configs.SPKEY.SIKADWA_TOKEN))                    //  token
            put("apiVersion","v3")                                                      //  接口版本
            put("androidId", AnalyticsUtil.getAndroidId())                                    //  安卓id
            put("advertId", AnalyticsUtil.getAdId())                                          //  广告id
            put("aduid", AnalyticsUtil.getAdId())                                             //  广告id
            put("aduidPath", AnalyticsUtil.getAndroidId())                                    //  广告地址
            put("isLimitAdTrackingEnabled", AnalyticsUtil.getAdEnabled().toString())          //  是否限制广告id，1是 0否
            put("userId", Configs.getSPString(Configs.SPKEY.SIKADWA_USERID))                  //  userId
            put("version", BuildConfig.VERSION_CODE)                                          //  app版本号
            put("timp",System.currentTimeMillis())                                            //  时间戳
            put("country", Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE_COUNTRY))       //  国家标识
            put("tzid", Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE_ID))               //  当前时区id
            put("localTimestamp","${System.currentTimeMillis()}")                       //时间戳
//            put("path","")                                                                        //  传映射后的接口路径，不带前面的/号
        }
        return this
    }

}